/**
 * 给定一个数组，问将数组改为排列最少需要多少代价
 * 首先将[1, N]之内的数排除，然后有2个集合
 * 目标集合，与手头还有的数的集合
 * 每一次均取最小的数进行操作即可
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;
int N;
vi A;

llt proc(){
    multiset<int> left;
    vi flag(N + 1, 0);
    for(auto i : A){
        if(1 <= i and i <= N){
            if(flag[i] == 0){
                flag[i] = 1;
            }else{
                left.insert(i);
            }
        }else{
            left.insert(i);
        }
    }

    set<int> want;
    for(int i=1;i<=N;++i)if(0 == flag[i])want.insert(i);

    llt ans = 0;
    while(1){
        if(want.empty()) break;

        int tmp = *want.begin();
        want.erase(want.begin());

        auto candi = *left.begin();
        left.erase(left.begin());

        auto cha = abs(tmp - candi);
        ans += cha;
    }
    return ans;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1; 
    // cin >> nofkase;
    while(nofkase--){
        cin >> N;
        A.assign(N, {});
        for(auto & i : A) cin >> i;
        cout << proc() << endl;
    }
    return 0;
}